<!--
 * @Descripttion: 
 * @version: 
 * @Author: lsy
 * @Date: 2022-01-25 09:26:19
 * @LastEditors: lsy
 * @LastEditTime: 2022-01-26 17:24:52
-->
<template>
  <h1 @click="changeLogin">hello，I am master的{{ msg }}</h1>

  <a href="/app1">去app1</a>
  
  <br/><br/><br/>

  <a  href="/app2">去app2</a>

  <div id="container" />
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { start } from "qiankun";

onMounted(() => {
  if (!window.qiankunStarted) {
    window.qiankunStarted = true;
    start();
  }
}
)

const changeLogin = () => {
  GlobalState.setGlobalState({ msg: "head", })
}

const msg = ref("");

GlobalState.onGlobalStateChange((state, prev) => {
  // state: 变更后的状态; prev 变更前的状态
  msg.value = state.msg;
}, true)

</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
